<template>
  <div class="wrap">
    <!-- 搜索 -->
    <el-card style="height: 30%">
      <!-- 表单搜索 -->
      <el-form size="mini" ref="batchJsForm" :label-width="formLabelWidth">
        <!-- 表头查询 -->
        <!-- 第一行 -->
        <el-row type="flex" justify="space-between">
          <el-col :span="5">
            <!-- 调度 -->
            <el-form-item label="调度:">
              <el-select
                v-model="queryDetailParam.regulationOrgId"
                placeholder="请选择"
                @change="regulationOrgChange(queryDetailParam.regulationOrgId)"
              >
                <el-option
                  v-for="item in dispatchList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <FuzzyQueryInput
              @inputChange="inputChange"
              ref="stationRef"
              :api="queryStationNameList"
              labelText="场站名称:"
              :style="{ width: '110%' }"
              @handleClear="handleClear_1"
              :queryParam1="queryParam1"
            />
          </el-col>
          <el-col :span="5">
            <!-- 升压站接入等级 -->
            <el-form-item label="升压站接入等级:">
              <el-select
                v-model="queryDetailParam.voltageLevelCode"
                placeholder="请选择"
                :popper-append-to-body="false"
              >
                <el-option
                  v-for="item in voltageLevelLists"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="产权单位:">
              <el-input
                v-model.trim="queryDetailParam.ownersName"
                clearable
                maxlength="40"
                placeholder="输入产权单位名称"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <!-- 第二行 -->
        <el-row type="flex" justify="space-between">
          <el-col :span="5">
            <!-- 调度 -->
            <el-form-item label="是否已整站投产:">
              <el-select
                v-model="queryDetailParam.isProduction"
                placeholder="请选择"
                clearable
              >
                <el-option
                  v-for="item in isYes"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="整站容量范围:">
              <el-input
                v-model.trim="queryDetailParam.capStart"
                clearable
                type="number"
                style="width: calc(50% - 22px)"
                oninput="value= value.length>40?value.slice(0,40):value"
              />
              <span style="padding-right: 5px; padding-left: 5px">-</span>
              <el-input
                v-model.trim="queryDetailParam.capEnd"
                clearable
                type="number"
                style="width: calc(50% - 22px)"
                oninput="value= value.length>40?value.slice(0,40):value"
              />
              <span style="margin-left: 5px; font-size: 12px">MW</span>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="最大上下调节能力:">
              <el-input
                v-model.trim="queryDetailParam.powerStart"
                clearable
                type="number"
                oninput="value= value.length>40?value.slice(0,40):value"
                style="width: calc(50% - 22px)"
              ></el-input>
              <span style="padding-right: 5px; padding-left: 5px">-</span>
              <el-input
                v-model.trim="queryDetailParam.powerEnd"
                type="number"
                oninput="value= value.length>40?value.slice(0,40):value"
                clearable
                style="width: calc(50% - 22px)"
              ></el-input
              ><span style="margin-left: 5px; font-size: 12px">MW</span>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="每分钟调节速率:">
              <el-input
                v-model.trim="queryDetailParam.speedStart"
                clearable
                type="number"
                oninput="value= value.length>40?value.slice(0,40):value"
                style="width: calc(50% - 22px)"
              ></el-input>
              <span style="padding-right: 5px; padding-left: 5px">-</span>
              <el-input
                v-model.trim="queryDetailParam.speedEnd"
                type="number"
                oninput="value= value.length>40?value.slice(0,40):value"
                clearable
                style="width: calc(50% - 22px)"
              ></el-input
              ><span style="margin-left: 5px; font-size: 12px">MW</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row type="flex" justify="space-between">
          <el-col :span="5">
            <el-form-item label="最大调节能力持续响应时间:" label-width="160px">
              <el-input
                v-model.trim="queryDetailParam.powerDurationStart"
                clearable
                type="number"
                oninput="value= value.length>40?value.slice(0,40):value"
                style="width: calc(50% - 16px)"
              ></el-input>
              <span style="padding-right: 5px; padding-left: 5px">-</span>
              <el-input
                v-model.trim="queryDetailParam.powerDurationEnd"
                type="number"
                oninput="value= value.length>40?value.slice(0,40):value"
                clearable
                style="width: calc(50% - 16px)"
              ></el-input
              ><span style="margin-left: 5px; font-size: 12px">S</span>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="整站投产时间:">
              <el-date-picker
                v-model="queryDetailParam.productionTime"
                type="date"
                :value-format="'yyyy-MM-dd'"
                placeholder="选择日期"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="是否已投入:">
              <el-select
                v-model="queryDetailParam.isRegulation"
                placeholder="请选择"
                clearable
                :popper-append-to-body="false"
              >
                <el-option
                  v-for="item in isYes"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="上调下调是否投入:">
              <el-select
                v-model="queryDetailParam.adjustRegulationCode"
                placeholder="请选择"
                :popper-append-to-body="false"
              >
                <el-option
                  v-for="item in adjustRegulationLists"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <!-- 第三行 -->
        <el-row type="flex">
          <el-col :span="5">
            <el-form-item label="是否具备惯量响应:">
              <el-select
                v-model="queryDetailParam.isResponse"
                placeholder="请选择"
                clearable
                style="width: 100%"
              >
                <el-option
                  v-for="item in isYes"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-button
              style="margin-left: 37%"
              type="primary"
              class="newButtonColor SearchBTN"
              @click="searchList"
              size="mini"
              >检索</el-button
            >
            <el-button
              class="newButtonColor SearchBTN"
              size="mini"
              @click="resetSearchList"
              >重置</el-button
            >
          </el-col>
        </el-row>
      </el-form>
    </el-card>
    <!-- 表格 -->
    <el-card style="margin-top: 20px; height: 68%; margin-bottom: 20px">
      <CleanForm
        :searShow="true"
        :showColumnHandle="false"
        :api="getWindPowerList"
        :queryParam="queryDetailParam"
        :fieldList="headList"
        :tableOptionWidth="200"
        :showColumnSetting="false"
        :page="false"
        :dialogPage="true"
        :showExportBtn="false"
        ref="windPowerTable"
      >
        <template slot="tableTopOptionRight">
          <!-- 这里是写表格上方的按钮 -->
          <div>
            <!-- <span class="operateButton" @click="addWindPower" operate="add"
              ><img src="@/assets/icon/389.png" /> 新增</span
            > -->
            <span
              class="operateButton b-border"
              @click="copyWindPower()"
              operate="copy"
              ><img src="@/assets/icon/394.png" /> 复制</span
            >
            <span
              v-if="isHide"
              class="operateButton b-border"
              @click="editWindPower()"
              operate="edit"
              ><img src="@/assets/icon/392.png" /> 编辑</span
            >
            <span
              class="operateButton b-border"
              @click="deleteWindPower()"
              operate="delete"
              ><img src="@/assets/icon/393.png" /> 删除</span
            >
            <span
              class="operateButton b-border"
              @click="exportExcel()"
              operate="export"
              ><img src="@/assets/icon/395.png" /> 导出</span
            >
          </div>
        </template>
      </CleanForm>
    </el-card>
    <!-- 新增弹框 -->
    <div v-if="dialogFormVisible">
      <el-dialog
        :title="addDialogVisibleTitle"
        :visible.sync="dialogFormVisible"
        width="1500px"
        top="7vh"
      >
        <windPower-edit
          ref="childRules"
          :detailForm="getFrom"
          :dispatchLists="dispatchList"
          :stationTypeLists="stationTypeLists"
          :voltageLevelLists="voltageLevelLists"
          :adjustRegulationLists="adjustRegulationLists"
          :queryDetailParam="queryDetailParam"
          :operate="operate"
        ></windPower-edit>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" size="small" @click="saveForm()">{{
            this.addDialogVisibleTitle == '编辑' ? '确认编辑' : '确认新增'
          }}</el-button>
          <el-button
            type="primary"
            v-if="this.addDialogVisibleTitle != '编辑'"
            size="small"
            @click="resetCon()"
            >重置
          </el-button>
          <el-button size="small" @click="dialogFormVisible = false"
            >退出
          </el-button>
        </div>
      </el-dialog>
    </div>
    <!-- 预览弹框 -->
    <el-dialog
      title="预览"
      width="70%"
      :visible.sync="dialogPreVisible"
      @close="
        () => {
          pdf = ''
        }
      "
    >
      <iframe
        style="width: 100%; height: 450px"
        frameborder="0"
        width="100%"
        height="620px"
        :src="pdf"
        v-if="pdf"
        type="application/x-google-chrome-pdf"
        ref="previewFrame"
      ></iframe>
      <div
        class="table-html-wrap"
        v-if="!pdf"
        style="width: 100%; height: 420px; overflow: auto"
        id="tableHtml"
      ></div>
    </el-dialog>
  </div>
</template>
<script>
import WindPower from './windpower.js'
export default WindPower
</script>
<style lang="scss" scoped>
::v-deep .el-card__body {
  height: 100%;
}
.table-html-wrap {
  overflow: hidden;
  overflow-y: auto;
}

.table-html-wrap ::v-deep table {
  // color: red;
  border-right: 1px solid #000;
  border-bottom: 1px solid #000;
  border-collapse: collapse;
  margin: auto;
}

.table-html-wrap ::v-deep table td {
  border-left: 1px solid #000;
  border-top: 1px solid #000;
  white-space: nowrap;
  text-align: center;
  padding: 0.5rem;
}

.table-html-wrap ::v-deep tbody tr:nth-of-type(1) {
  font-weight: bold;
  font-size: 20px;
}

.dialog-footer {
  text-align: end;
}

.wrap {
  width: 100%;
  height: 100%;
  /* background-color: rgb(195, 188, 241); */
}

.title {
  border: 1px solid grey;
  border-radius: 4px;
  width: 200px;
  text-align: center;
}

.operateButton {
  cursor: pointer;
  font-size: 12px !important;
  padding: 8px;

  img {
    transform: translateY(-2px);
  }
}

.operateButton::after {
  display: inline-block;
  content: '';
  width: 1px;
  height: 18px;
  margin: 0 3px;
  transform: translate(6px, 3px);
  background: #000;
}

.operateButton:last-child::after {
  display: none;
}

::v-deep .el-select--mini {
  width: 100%;
}

::v-deep .el-date-editor {
  width: 100%;
}

::v-deep .el-scrollbar__thumb {
  background: #000;
  display: none;
}

// ::-webkit-scrollbar-thumb {
//   // display: none;
// }
::v-deep .el-table__empty-block {
  justify-content: left;
  text-align: left;
  padding-left: 40%;
}

// ::v-deep .el-select-dropdown {
//   position: absolute !important;
//   top: 80% !important;
//   left: 0px !important;
// }

::v-deep .el-card {
  border-radius: 4px;
  border: 1px solid #ebeef5;
  background-color: #fff;
  overflow: visible !important; //溢出不隐藏   隐藏的话，下拉框看不到全部数据
  color: #303133;
  transition: 0.3s;
}
</style>
